package ltd.dujiabao.dualwrite.dao;

import ltd.dujiabao.dualwrite.domain.Person;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Bowie Du
 * @date 2025/1/29 16:43
 */

@Repository
public interface PersonRepository extends JpaRepository<Person, Long> {
//    @Query("delete from Person where id = :id")
    @Query(value = "delete from person where id = :id", nativeQuery = true)
    @Transactional(rollbackFor = Exception.class)
    @Modifying(flushAutomatically = true, clearAutomatically = true)
    void deleteById(@Param("id") Long id);
}
